Imports MySql.Data.MySqlClient
Public Class frmCanDoiTaiKhoan_Ngay
    Private data As DataTable
    Private da As MySqlDataAdapter
    Dim sqlQuery As String

    Private Sub frmCanDoiTaiKhoan_Ngay_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        moduleUtils.setDinhDangVietNam()

        Me.TuNgay_DateTimePicker.Value = moduleUtils.getNgayDauThang(Today.Year, Today.Month)
        Me.DenNgay_DateTimePicker.Value = moduleUtils.getNgayCuoiThang(Today.Year, Today.Month)

        'Dim nam As Integer = Me.txtNam.Text.Trim
        'Dim thang As Integer = Me.txtThang.Text
        'Dim loadTonCDTK As Integer = moduleUtils.loadTonCDTK(nam, Format(thang, "00"))

        'If loadTonCDTK = 1 Then
        '    Dim recycleID As String = nam & Format(thang, "00")
        '    Dim sqlQuery = "SELECT * FROM tbl_dot_temp_toncdtk WHERE recycleID = '" & recycleID & "' ORDER BY ma_taikhoan"
        '    Dim record As ArrayList = moduleDatabaseConn.loadDataTable(data, da, sqlQuery)
        '    da = record.Item(0)
        '    data = record.Item(1)
        '    Me.gridTonCDTK.DataSource = data
        '    Dim length As Integer = data.Select.Length
        '    For index As Integer = 0 To length - 1
        '        Dim cuoivn As Double = (Me.gridTonCDTK.Item(2, index).Value + Me.gridTonCDTK.Item(4, index).Value) - (Me.gridTonCDTK.Item(3, index).Value + Me.gridTonCDTK.Item(5, index).Value)

        '        If cuoivn > 0 Then
        '            Me.gridTonCDTK.Item(8, index).Value = cuoivn
        '        Else
        '            Me.gridTonCDTK.Item(9, index).Value = Math.Abs(cuoivn)
        '        End If
        '    Next

        '    da.Update(data)
        '    data.AcceptChanges()
        'End If
    End Sub

    Private Sub btnInBaoCao_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInBaoCao.Click
        Dim myForm As FrmCrCanDoiTaiKhoan_Ngay = New FrmCrCanDoiTaiKhoan_Ngay

        myForm.setThang(CDate(Me.TuNgay_DateTimePicker.Value))
        myForm.setNam(CDate(Me.DenNgay_DateTimePicker.Value))
        myForm.Show()
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
    End Sub

    Private Sub btnXemCDTK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnXemCDTK.Click

        Me.Cursor = Cursors.WaitCursor
        Dim loadTonCDTK As Integer = tonghop.loadTonCDTK_Ngay(CDate(Me.TuNgay_DateTimePicker.Value), CDate(Me.DenNgay_DateTimePicker.Value))
        Me.Cursor = Cursors.Default

        If loadTonCDTK = 1 Then
            Dim sqlQuery = "SELECT * FROM tbl_dot_temp_toncdtk_Ngay  ORDER BY ma_taikhoan "
            Dim record As ArrayList = moduleDatabaseConn.loadDataTable(data, da, sqlQuery)
            da = record.Item(0)
            data = record.Item(1)
            Me.gridTonCDTK.DataSource = data
            'Dim length As Integer = data.Select.Length
            'For index As Integer = 0 To length - 1
            '    Dim cuoivn As Double = (Me.gridTonCDTK.Item(2, index).Value + Me.gridTonCDTK.Item(4, index).Value) - (Me.gridTonCDTK.Item(3, index).Value + Me.gridTonCDTK.Item(5, index).Value)

            '    If cuoivn > 0 Then
            '        Me.gridTonCDTK.Item(8, index).Value = cuoivn
            '    Else
            '        Me.gridTonCDTK.Item(9, index).Value = Math.Abs(cuoivn)
            '    End If
            'Next

            'da.Update(data)
            'data.AcceptChanges()
        End If
    End Sub

End Class